<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>计算数组的交集，用回调函数比较数据</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.array-uintersect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_uintersect</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">array_uintersect</span> &mdash; <span class="dc-title">计算数组的交集，用回调函数比较数据</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.array-uintersect-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>array_uintersect</strong></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$array1</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$array2</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$...</code></span>
   ], <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$value_compare_func</code></span>
   ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>array_uintersect()</strong></span> 返回一个数组，该数组包含了所有在
   <code class="parameter">array1</code> 中也同时出现在所有其它参数数组中的值。数据比较是用回调函数进行的。
   此比较是通过用户提供的回调函数来进行的。如果认为第一个参数小于，等于，或大于第二个参数时必须分别返回一个小于零，等于零，或大于零的整数。
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.array-uintersect-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">array1</code></dt>

     <dd>

      <p class="para">
       第一个数组。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">array2</code></dt>

     <dd>

      <p class="para">
       第二个数组。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">value_compare_func</code></dt>

     <dd>

      <p class="para">
       在第一个参数小于，等于或大于第二个参数时，该比较函数必须相应地返回一个小于，等于或大于 0 的整数。
      </p>
      <div class="methodsynopsis dc-description"><span class="methodname"><span class="replaceable">callback</span></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$a</code></span>, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$b</code></span> ) : <span class="type">int</span></div>

     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.array-uintersect-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an array containing all the values of <code class="parameter">array1</code>
   that are present in all the arguments.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.array-uintersect-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-6076">
    <p><strong>Example #1 <span class="function"><strong>array_uintersect()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$array1&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"a"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"green"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"b"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"brown"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"c"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"blue"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"red"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$array2&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"a"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"GREEN"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"B"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"brown"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"yellow"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"red"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">array_uintersect</span><span style="color: #007700">(</span><span style="color: #0000BB">$array1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$array2</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"strcasecmp"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [a] =&gt; green
    [b] =&gt; brown
    [0] =&gt; red
)
</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.array-uintersect-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="array_intersect.html" class="function" rel="rdfs-seeAlso">array_intersect()</a> - 计算数组的交集</span></li>
    <li class="member"><span class="function"><a href="array_intersect_assoc.html" class="function" rel="rdfs-seeAlso">array_intersect_assoc()</a> - 带索引检查计算数组的交集</span></li>
    <li class="member"><span class="function"><a href="array_uintersect_assoc.html" class="function" rel="rdfs-seeAlso">array_uintersect_assoc()</a> - 带索引检查计算数组的交集，用回调函数比较数据</span></li>
    <li class="member"><span class="function"><a href="array_uintersect_uassoc.html" class="function" rel="rdfs-seeAlso">array_uintersect_uassoc()</a> - 带索引检查计算数组的交集，用单独的回调函数比较数据和索引</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>